#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct STU
{
	int iId;
	char caName[32];
	float fScore;
}STU;

int main(int argc, char* argv[])
{
	FILE *file = fopen(argv[1], "wb");
	if (NULL == file)
	{
		exit(EXIT_FAILURE);
	}
	printf("open %s ok\n", argv[1]);
#if 0
	STU stu = {1001, "jack", 89};
	int ret = fwrite(&stu, sizeof(STU), 1, file);
	printf("ret = %d\n", ret);
#endif
	STU stu[5] = {{1001, "jack", 90}
	              , {1002, "rose", 78}
	              , {1003, "tony", 99}
	              , {1004, "peter", 88}
	              , {1005, "kitty", 91}};
	int ret = fwrite(stu, sizeof(STU), 5, file);
	printf("ret=%d\n", ret);


	fclose(file);

	return 0;
}
